package 第一题;

public class HomeWork3  implements Runnable{
    private int number = 80;  //总共80份学习笔记
    private int count = 0;    //发第几份

    @Override
    public void run() {
        while (true) {
            synchronized (this) {
                if (number <= 0) {
                    break;
                }
                try {
                    Thread.sleep(400);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                number--;
                count++;
                System.out.println(Thread.currentThread().getName() + "正在发第" + count + "份学习笔记，还有" + number + "份学习笔记。");
            }
        }
    }

    public static void main(String[] args) {
        HomeWork3 homeWork3 = new HomeWork3();
        new Thread(homeWork3, "老师a").start();
        new Thread(homeWork3, "老师b").start();
        new Thread(homeWork3, "老师c").start();
    }
}
